#include "UMLBox.h"
#include "DiagramVisitor.h"
#include "../util/qconv.h"

UMLBox::UMLBox(const QString& text)
:	UMLObject(text),
	_rect(0, 0, 10, 5)
{
}

UMLBox& UMLBox::operator=(const UMLObject& obj)
{
	const UMLBox& box = *static_cast<const UMLBox*>(&obj);

	_rect = box._rect;
	UMLObject::operator=(obj);

	// UMLObject::operator= did notifyObservers()

	return *this;
}

UMLBox* UMLBox::clone() const
{
	return new UMLBox(*this);
}

void UMLBox::accept(DiagramVisitor& dv)
{
	dv.visit(*this);

	// Don't notifyObservers(). If the visitor modifies us, that modification
	// will generate the notification.
}

QPoint UMLBox::position() const
{
	return _rect.topLeft();
}

void UMLBox::setPosition(const QPoint& p)
{
	_rect.moveTo(p);

	notifyObservers();
}

QRect UMLBox::rect() const
{
	return _rect;
}

void UMLBox::setSize(const QSize& s)
{
	_rect.setSize(s);

	notifyObservers();
}

void UMLBox::setEnd(const QPoint& br)
{
	_rect.setBottomRight(br);

	notifyObservers();
}

